<script>
  highlight_subnav('goodslist');
</script>
<style type="text/css">
.tab-ui{
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
    text-align: center;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
}
.tab-ui li{
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.breviary{
    width:90px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
        display: inline-block;
}
.am-selected.am-dropdown {
    float:left;
}
</style>
 <!-- 内容区域 -->
 <div class="tpl-content-wrapper">
            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                
                                <div class="row">
                                    <div class="am-u-sm-6">
                                        <div  class="am-tabs am-tabs-d2 am-no-layout" style="margin: 10px;"> 
                                            <ul class="am-tabs-nav am-cf tab-ui" >
                                                <li class="am-active">
                                                    <a>待退押金列表</a>
                                                </li>
                                                <li><a href="<?php echo $base_url;?>admin/refund/refunded">已退押金列表</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                  
                            <div class="widget-body  am-fr">

                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                                    <div class="am-form-group">
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a href="<?php echo $base_url ?>admin/refund/exportToRefund?activity_id=<?php if(isset($_GET['activity_id'])){echo $_GET['activity_id'];}?>&sourch=<?php if(isset($_GET['sourch'])){echo $_GET['sourch'];}?>&start_time=<?php if(isset($_GET['start_time'])){echo $_GET['start_time'];}?>&end_time=<?php if(isset($_GET['end_time'])){echo $_GET['end_time'];}?>" class="am-btn am-btn-default am-btn-success" id="export"><span class="am-icon-plus"></span> 导出明细表</a>&nbsp;&nbsp;&nbsp;                                                
                                            </div>
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a href="<?php echo $base_url ?>admin/refund/exportToTotalrefund?activity_id=<?php if(isset($_GET['activity_id'])){echo $_GET['activity_id'];}?>&sourch=<?php if(isset($_GET['sourch'])){echo $_GET['sourch'];}?>&start_time=<?php if(isset($_GET['start_time'])){echo $_GET['start_time'];}?>&end_time=<?php if(isset($_GET['end_time'])){echo $_GET['end_time'];}?>" class="am-btn am-btn-default am-btn-success" id="export"><span class="am-icon-plus"></span> 导出统计表</a>&nbsp;&nbsp;&nbsp;                                                
                                            </div>
                                            <div class="am-btn-group am-btn-group-xs">
                                                <span>导入--></span>
                                            </div>
                                            <div class="am-btn-group am-btn-group-xs">
                                                <!-- <a href="" class="am-btn am-btn-default am-btn-success" id="import"><span class="am-icon-plus"></span> </a> -->
                                                <input id="import" type="file" multiple="" class="file-input">
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <form action="index" method="get" id="form">
                                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                                        <div class="am-form-group">
                                            <label for="user-weibo" class="am-u-sm-4 am-form-label">开始时间</label>
                                            <div class="am-u-sm-8">
                                                <input type="text" id='start_time' name='start_time'  value="<?php echo isset($_GET['start_time']) ? $_GET['start_time']: ''?>" placeholder="点击选择时间">                           
                                            
                                            </div>
                                        </div>
                                    </div>
                                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                                        <div class="am-form-group">
                                            <label for="user-weibo" class="am-u-sm-4 am-form-label">结束时间 </label>
                                            <div class="am-u-sm-8">
                                                <input type="text" id='end_time' name='end_time' value="<?php echo isset($_GET['end_time']) ? $_GET['end_time']:''?>" placeholder="点击选择时间">
                                            
                                            </div>
                                        </div>
                                    </div>
                                    <div style="height:20px;width:100%;
                                    float: left;"></div>
                                    <div class="row" >
                                        <div class="am-u-sm-12">
                                             <div class="am-u-sm-6 am-u-md-6 am-u-lg-3">
                                                <div class="am-form-group tpl-table-list-select">
                                                    <select data-am-selected="{btnSize: 'sm'}" name="activity_id" id='activity_id' >
                                                     <?php foreach($activity as $key => $value){?>
                                                          <option value="<?php echo $value['activity_id']?>" <?php if(isset($_GET['activity_id'])){if($_GET['activity_id'] == $value['activity_id']){echo "selected";}}?>><?php echo $value['activity_name']?></option>
                                                          <?php }?>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3 ">
                                                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                                    <input type="text" name="sourch" value="<?php if(isset($_GET['sourch'])){echo $_GET['sourch'];}?>" placeholder="请输入用户姓名/用户手机号/银行账号" class="am-form-field ">
                                                    <span class="am-input-group-btn">
                                                        <input class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="submit" id="submitform" value="搜索">
                                                    </span>
                                                </div>
                                            </div>
                                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-6 ">
                                            &nbsp;
                                            </div>
                                        </div>
                                    </div>
                               
                                </form>
                             <div class="am-u-sm-12">
                                    <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                                        <thead>
                                            <tr>
                                                <th width="3%">序号</th>
                                                <th width="4%">订单号</th>
                                                <th width="5%">订单详情号</th>
                                                <th width="7%">用户姓名</th>
                                                <th width="10%">用户手机号</th>
                                                <th width="9%">银行账号</th>
                                                <th width="9%">银行名称</th>
                                                <th width="9%">联行号</th>
                                                <th width="9%">状态</th>
                                                <th width="5%">产品总数</th>
                                                <th width="5%">总金额</th>
                                                <th width="5%">已退押金</th>
                                                <th width="5%">待退金额</th>
                                                <th width="7%">支付方式</th>
                                                <th width="8%">下单时间</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php foreach($torefund as $key => $value): ?>
                                                <tr class="gradeX">
                                                        <td class="am-text-middle"><?php echo $key+1; ?></td>
                                                        <td class="am-text-middle"><?php echo $value['order_id']; ?></td>
                                                        <td class="am-text-middle"><?php echo $value['order_detail_id']; ?></td>
                                                        <td class="am-text-middle"><?php echo $value['username']; ?></td>
                                                        <td class="am-text-middle " ><?php echo $value['mobile']; ?></td>
                                                        <td class="am-text-middle "><div class="breviary" title="<?php echo $value['cardid']; ?>"><?php echo $value['cardid']; ?></div></td>
                                                        <td class="am-text-middle" ><div class="breviary" title="<?php echo $value['rhname']; ?>"><?php echo $value['rhname']; ?></div></td>
                                                        <td class="am-text-middle"><div class="breviary" title="<?php echo $value['rhcode']; ?>"><?php echo $value['rhcode']; ?></div></td>
                                                        <td class="am-text-middle">
                                                            <?php 
                                                                if($value['status'] == 1)
                                                                    echo '支付成功';
                                                                else if($value['status'] == 2)
                                                                    echo '已发货'; 
                                                                else if($value['status'] == 3)
                                                                    echo '未支付';
                                                                else if($value['status'] == 4)
                                                                    echo '超时';
                                                                else if($value['status'] == 5)
                                                                    echo '已退押金';
                                                            ?>
                                                        </td>
                                                        
                                                        <td class="am-text-middle"><?php echo $value['amount']; ?></td>
                                                        <td class="am-text-middle"><?php echo $value['price']; ?></td>
                                                        <td class="am-text-middle"><?php echo $value['return_money']; ?></td>
                                                        <td class="am-text-middle"><?php
                                                            if($activity_class == 1){
                                                                echo $value['price'];
                                                            }else{
                                                                echo $value['price']/$activity_period;
                                                            }
                                                        ?></td>
                                                        <td class="am-text-middle">
                                                            <?php 
                                                                if($value['paytype'] == 1 || $value['paytype'] == 2)
                                                                    echo '微信';
                                                                else if($value['paytype'] == 3)
                                                                    echo '支付宝';
                                                            ?>
                                                        </td>
                                                        <td class="am-text-middle breviary" >
                                                            <div class="breviary" title="<?php echo date('Y-m-d H:i:s', $value['create_time']); ?>">
                                                            <?php 
                                                                echo date('Y-m-d H:i:s', $value['create_time']);
                                                            ?>
                                                            </div>
                                                        </td>
                                                </tr>
                                            <?php endforeach; ?>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="am-u-lg-12 am-cf">
                                    <div class="am-fr">
                                        <ul class="am-pagination tpl-pagination">
                                            <?php echo $page; ?>    
                                            <!-- <li class="am-disabled"><a href="#">«</a></li>
                                            <li class="am-active"><a href="#">1</a></li>
                                            <li><a href="#">2</a></li>
                                            <li><a href="#">3</a></li>
                                            <li><a href="#">4</a></li>
                                            <li><a href="#">5</a></li>
                                            <li><a href="#">»</a></li> -->
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div> 
                </div>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript">
    $(function(){
        
        //导出excel文件
        $("#export").on('click', function(){
            
            var activity_id = $('#activity_id option:selected').val();
            window.location.href = '<?php echo $base_url ?>admin/refund/exportToRefund?' 
                                    + 'activity_id=' + activity_id;
        });

        //导入excel文件
        $("#import").on('click', function(){
            
        });

        //导入excel文件
        $("#import").on('change',function(){
            var currentObj = $(this);
            var fd = new FormData();
            fd.append("userfile", currentObj.get(0).files[0]);
            $.ajax({
            url: "<?php echo $base_url; ?>admin/refund/importRefunds",
            type: "POST",
            processData: false,
            contentType: false,
            dataType: "json",
            data: fd,
            success: function(data) {
                console.log(data);
                //导入失败
                if(data.errcode != 0)
                {
                    alert(data.errmsg);
                }
                else
                {
                    alert('导入成功');
                }
            }
            });
        });
    })
</script>
<script type="text/javascript" src="/static/laydate/laydate.js"></script>
<script type="text/javascript">
    $(function () {
        $("#status").change(function () {
            var start_time = $('#start_time').val();
            var end_time = $('#end_time').val();
            if (start_time > end_time) {
                alert('开始时间不能大于结束时间');
                return;
            }
            $("#form1").submit();
        });

        laydate({
            elem: '#start_time'
        });
        laydate({
            elem: '#end_time'
        });


    });
    function submitform() {
        //提交表单
        var start_time = $('#start_time').val();
        var end_time = $('#end_time').val();
        if (start_time > end_time) {
            alert('开始时间不能大于结束时间');
            return;
        }

        $("#form1").submit();
    }

</script>
</html>


       
